<template>
	<view>
		<uni-card>
		 <view style="display: flex; align-items: center; cursor: default">
	 <image :src="user.avatar || 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'" alt="" style="width: 55px; height: 55px; margin-left: -10px;margin-right: 15px;"></image>
		             <span style="font-size: 18px;font-weight: bold;">{{user.username || '未知用户'}}</span> 
				
					
		              </view>
		</uni-card>
					  
					  <uni-card>
	 <view style="background-color: white;margin: 5px 0;border-radius: 10px;">
				<uni-row>
					<uni-col :span="6">
						<view class="grid-item-box" @click="collect">
							<image mode="widthFix" style="width: 50%;" src="../../static/icon/收藏.svg"></image>
							<text class="p1" style="font-size: 13px;margin-top: 5px;">我的收藏</text>
						</view>
					</uni-col>	
					<uni-col :span="6">
						<view class="grid-item-box"@click="news">
						<image mode="widthFix" style="width: 50%;" src="../../static/icon/系统公告.svg">
							</image>
							<text class="p1" style="font-size: 13px;margin-top: 5px;">系统公告</text>
						</view>
					</uni-col>	
					<uni-col :span="6">
						<view class="grid-item-box" @click="comment">
							<image mode="widthFix" style="width: 50%;" src="../../static/icon/待评价-我的.svg"></image>
							<text class="p1" style="font-size: 13px;margin-top: 5px;">评价中心</text>
						</view>
					</uni-col>	
					<uni-col :span="6">
						<view class="grid-item-box" @click="password">
							<image mode="widthFix" style="width: 50%;" src="../../static/icon/修改密码.svg"></image>
							<text class="p1" style="font-size: 13px;margin-top: 5px;">修改密码</text>
						</view>
					</uni-col>	
				</uni-row>	 		  
	 </view>
					</uni-card>  

	<view  style="margin-left: 15px;margin-right: 15px;">
				
				<button @click="person"style="background-color: #FFFFFF;font-size: 15px;border-radius: 5px;display: flex;align-items: center;">
				
					<image src="../../static/icon/个人信息.svg" style="width: 22px;height: 22px;margin-right: 10px;"></image>
				  <span class="p1" style="display: flex;align-items: center;margin-right: -60px;">个人信息</span>
				<image src="../../static/icon/普通向右箭头.svg" style="width: 60rpx;height: 60rpx;margin-left: 200px"></image>
				</button>
	
	<view style="height: 0.5px;width:100%;background-color: #DCDCDC;"></view>
				
				<button @click="comment"style="background-color: #FFFFFF;font-size: 15px;border-radius: 5px;display: flex;align-items: center;">
					<image src="../../static/icon/反馈.svg" style="width: 22px;height: 22px;margin-right: 10px;"></image>
				 <span class="p1" style="display: flex;align-items: center;margin-right: 0px;">反馈中心</span>
				<image src="../../static/icon/普通向右箭头.svg" style="width: 60rpx;height: 60rpx;padding-left:140px;"></image>
				</button>
	
	<view style="height: 0.5px;width:100%;background-color: #DCDCDC;"></view>

					<button @click="aboutUs"style="background-color: #FFFFFF;font-size: 15px;border-radius: 5px;display: flex;align-items: center;">
					<image src="../../static/icon/关于我们.svg" style="width: 22px;height: 22px;margin-right: 10px;"></image>	
					   <span class="p1" style="display: flex;align-items: center;margin-right: -60px;">关于天气</span>
					<image src="../../static/icon/普通向右箭头.svg" style="width: 60rpx;height: 60rpx;margin-left: 200px"></image>
					</button>			
		<view style="height: 0.5px;width:100%;background-color: #DCDCDC;"></view>
					
					<button @click="refLogin"style="background-color: #FFFFFF;font-size: 15px;border-radius: 5px;display: flex;align-items: center;">
					<image src="../../static/icon/退出登录.svg" style="width: 22px;height: 22px;margin-right: 10px;"></image>	
					  <span class="p1" style="display: flex;align-items: center;margin-right: -60px;">退出登录</span>
					<image src="../../static/icon/普通向右箭头.svg" style="width: 60rpx;height: 60rpx;margin-left: 200px"></image>
					</button>	
	</view>
		
			
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value:'',
				  user: uni.getStorageSync('weather2024'),
				 mobile:uni.getStorageSync('weather2024').mobile,
			}
		},
		onLoad(){
			
		},
		created(){
		wx.showShareMenu({
			withShareTicket:true,
			menus:['shareAppMessage','shareTimeline']
		});	
		},
		
		onShareAppMessage(res){
			return{
				title: this.title,
				imageUrl:this.thumb
			}
		},
		onShareTimeline(res){
			return{
				title: this.title,
				imageUrl:this.thumb
			}
		},
	
		onShow(){
			
			  this.user= uni.getStorageSync('weather2024')
			if(!uni.getStorageSync('weather2024').mobile)
			{
			uni.showModal({
				title:"提示",
				content:"根据用户使用规则,需用户自行绑定手机号才可使用!",
				confirmText:"去绑定",
				success:function(res){
					if(res.confirm){
						console.log('用户点击了绑定按钮')
						uni.navigateTo({
							url: '/pages/user/bindMobile'
						})
					}else if(res.cancel){
						console.log('用户点击了取消按钮')
						uni.switchTab({
							url: '/pages/index/index'
						})
						uni.removeStorageSync('weather2024')
						
						uni.showModal({
							
							content: '登录异常，请返回重新登录',
							confirmText:"去登录",
							success:function(res){
								if(res.confirm){
									console.log('用户点击了去登录按钮')
									uni.redirectTo({
										url:'/pages/login/login',
									})
								}else if(res.cancel){
									console.log('用户点击了取消按钮')
								}
							}
						})
					}
				}
			})
			}
		},
		methods: {
			
			
			refLogin(){
				uni.removeStorageSync('weather2024')
				uni.redirectTo({
					url:'/pages/login/login',
				})
			},
		 	person(){
				uni.navigateTo({
					url:'/pages/user/userMessage',
				})
			},
			news(){
				uni.navigateTo({
					url:'/pages/user/news',
				})
			},
			password(){
				uni.navigateTo({
					url:'/pages/user/password',
				})
			},
			collect(){
				uni.navigateTo({
					url:'/pages/user/collect',
				})
			}, 
			aboutUs(){
				uni.navigateTo({
					url:'/pages/user/aboutUs',
				})
			}, 
			comment(){
				uni.navigateTo({
					url:'/pages/user/comment',
				})
			}, 
			bind(){
				uni.navigateTo({
					url:"/pages/user/bindMobile"
				})
			},
		}
	}
</script>

<style>
.grid-item-box{
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}
.p1{
		font-family: "Brush Script MT", "Lucida Handwriting", Cursive;
		font-weight: bolder;
	}
		
				.uni-badge-left-margin {
						margin-bottom: -22px;
					}	
						
</style>
